Skip to content

Invoke-PkProcessBatch no longer needs the kit's functions to be global - #94

Merged
HalRiveria-Bot merged 1 commit into
mainfrom
fix/batch-closures
Dec 1, 2026
Merged

HalRiveria-Bot merged 1 commit into
mainfrom
fix/batch-closures

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

Invoke-PkProcessBatch only worked when the kit's public functions were global. Two of its own callbacks are .GetNewClosure() blocks that call Complete-PkProcess and Write-PkMessage by name, and such a block only sees global functions. With the kit loaded for one module only, every batch failed with "The term 'Complete-PkProcess' is not recognized". Loading it the documented way isn't affected, since that imports the functions globally.

  • Both functions are captured before the closures, the way the private helpers already are. They're the only public functions the kit's own closures call.
  • Two comments said the batch relies on the global import; they no longer do.
  • The harness's static check (section AN) knows the two captured names.

Your own .GetNewClosure() callbacks still only see global functions; that part is PowerShell's.

Tests

Section Z loads the kit inside another module, for that module only, and runs a batch with one command that runs and one that can't start, so both closures are used.

  • On the old code, 5.1 and 7 both fail: a batch runs when the kit's functions aren't global (kit global=False error: The term 'Complete-PkProcess' is not recognized ...) and and reports the command that couldn't start.
  • With the fix, both pass.
  • Full harness: 704 passed on Windows PowerShell 5.1 and 704 passed on PowerShell 7.6.2, no skips.

🤖 Generated with Claude Code

Two of the batch's own closures called Complete-PkProcess and Write-PkMessage
by name. A .GetNewClosure() block only sees global functions, so a batch failed
with "'Complete-PkProcess' is not recognized" when the kit was loaded for one
module only. They're captured up front now, like the private helpers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HalRiveria-Bot
HalRiveria-Bot merged commit 69841c0 into main Dec 1, 2026
2 checks passed
@HalRiveria-Bot
HalRiveria-Bot deleted the fix/batch-closures branch December 1, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants